package io.renren.modules.frt.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.frt.entity.DistrictEntity;
import io.renren.modules.frt.entity.MonitorExcelEntity;
import io.renren.modules.frt.service.MonitorExcelService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author qibing.huang
 * @email abingtech@163.com
 * @date 2018-11-29 23:17:01
 */
@RestController
@RequestMapping("frt/monitorexcel")
public class MonitorExcelController {
    @Autowired
    private MonitorExcelService monitorExcelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("frt:monitorexcel:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = monitorExcelService.queryPage(params);

        return R.ok().put("page", page);
    }
    
    /**
	 * 列表，不分页
	 */
	@GetMapping("/list2")
	public R select(@RequestParam Map<String, Object> params){
		Map<String, Object> map = new HashMap<>();
		List<MonitorExcelEntity> list = monitorExcelService.selectByMap(map);
		
		return R.ok().put("list", list);
	}


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("frt:monitorexcel:info")
    public R info(@PathVariable("id") Long id){
        MonitorExcelEntity monitorExcel = monitorExcelService.selectById(id);

        return R.ok().put("monitorexcel", monitorExcel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("frt:monitorexcel:save")
    public R save(@RequestBody MonitorExcelEntity monitorExcel){
		monitorExcelService.insert(monitorExcel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("frt:monitorexcel:update")
    public R update(@RequestBody MonitorExcelEntity monitorExcel){
		monitorExcelService.updateById(monitorExcel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("frt:monitorexcel:delete")
    public R delete(@RequestBody Long[] ids){
		monitorExcelService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
